﻿
namespace Graphix.Charts.Values
{
    public class Candle
    {
        public Candle()
            : this(0, 0, 0, 0)
        {

        }

        public Candle(float startLine, float startBar, float endBar, float endLine)
        {
            this.StartLine = startLine;
            this.StartBar = startBar;
            this.EndBar = endBar;
            this.EndLine = endLine;
        }

        public float GetMinimum()
        {
            float min = this.StartLine;
            if (min > this.StartBar)
            {
                min = this.StartBar;
            }

            if (min > this.EndBar)
            {
                min = this.EndBar;
            }

            if (min > this.EndLine)
            {
                min = this.EndLine;
            }

            return min;
        }

        public float GetMaximum()
        {
            float max = this.StartLine;
            if (max < this.StartBar)
            {
                max = this.StartBar;
            }

            if (max < this.EndBar)
            {
                max = this.EndBar;
            }

            if (max < this.EndLine)
            {
                max = this.EndLine;
            }

            return max;
        }

        public float StartLine { get; set; }

        public float StartBar { get; set; }

        public float EndBar { get; set; }

        public float EndLine { get; set; }

        public override bool Equals(object obj)
        {
            Candle compared = obj as Candle;
            if (compared != null)
            {
                if (compared.EndBar == this.EndBar &&
                    compared.EndLine == this.EndLine &&
                    compared.StartBar == this.StartBar &&
                    compared.StartLine == this.StartLine)
                {
                    return true;
                }
            }

            return false;
        }
    }
}
